package org.example.recruitserver.Controller;

import jakarta.annotation.Resource;
import org.example.recruitserver.mapper.RecruitListMapper;
import org.example.recruitserver.model.AJobListModel;
import org.example.recruitserver.model.RecruitNameModel;
import org.example.recruitserver.model.ajobModel.JsonDataModel;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
public class AJobFindLikeController {

    @Resource
    RecruitListMapper rm;

    /**
     * 根据岗位名称进行模糊查询岗位列表
     * @param name 岗位名称
     * @return 返回查询到的数据
     */
    @GetMapping("/recruit/likeRecruitName")
    public JsonDataModel<AJobListModel> getFindLikeRecruitName(@RequestBody RecruitNameModel name) {
        List<AJobListModel> allLikeRecruit = rm.findAllLikeRecruit(name.getRnmName());
        JsonDataModel<AJobListModel> jsonDataModel = new JsonDataModel<>();
        if (allLikeRecruit != null) {
            jsonDataModel.setCode("200");
            jsonDataModel.setData(allLikeRecruit );
            jsonDataModel.setMsg("获取数据成功!");
            jsonDataModel.setDataSize((long) allLikeRecruit.size());
        } else {
            jsonDataModel.setCode("400");
            jsonDataModel.setData(allLikeRecruit);
            jsonDataModel.setMsg("获取数据失败!");
            jsonDataModel.setDataSize(0l);
        }
        return jsonDataModel;
    }
}
